package com.example.diethealthsystem.service;

import com.example.diethealthsystem.entity.ExerciseRecord;
import com.example.diethealthsystem.repository.ExerciseRecordRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

@Service
public class ExerciseRecordService {

    private final ExerciseRecordRepository exerciseRecordRepository;

    @Autowired
    public ExerciseRecordService(ExerciseRecordRepository exerciseRecordRepository) {
        this.exerciseRecordRepository = exerciseRecordRepository;
    }

    public List<ExerciseRecord> findAll() {
        return exerciseRecordRepository.findAll();
    }

    public Optional<ExerciseRecord> findById(Long id) {
        return exerciseRecordRepository.findById(id);
    }

    public ExerciseRecord save(ExerciseRecord exerciseRecord) {
        return exerciseRecordRepository.save(exerciseRecord);
    }

    public void deleteById(Long id) {
        exerciseRecordRepository.deleteById(id);
    }

    public List<ExerciseRecord> findByUserId(Long userId) {
        return exerciseRecordRepository.findByUserId(userId);
    }
} 